package com.leoman.welfare.dao;

import com.leoman.common.dao.IBaseJpaRepository;
import com.leoman.welfare.entity.WelfareData;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 福利数据统计
 * Created by 涂奕恒 on 2016/12/14.
 */
public interface WelfareDataDao extends IBaseJpaRepository<WelfareData> {

    @Query("select a from WelfareData a where a.welfare.id = ?1 and a.createDate = ?2")
    WelfareData findOneByWelfareIdAndCreateDate(Long welfareId, String createDate);

    @Query("select a from WelfareData a where a.welfare.id = ?1")
    List<WelfareData> findListByWelfareId(Long welfareId);

    @Query("select a from WelfareData a where a.welfare.id = ?1 and a.createDate >= ?2 and a.createDate <= ?3")
    Page<WelfareData> pageByWelfareId(Long welfareId, String startDate, String endDate, Pageable pageable);
}
